#ifndef MIPSSYSCALLINTERNAL_H
#define MIPSSYSCALLINTERNAL_H

#define MIPS_SYS_fork		4002
#define MIPS_SYS_read		4003
#define MIPS_SYS_write		4004
#define MIPS_SYS_open		4005
#define MIPS_SYS_close		4006
#define MIPS_SYS_unlink		4010
#define MIPS_SYS_execve		4011
#define MIPS_SYS_time		4013
#define MIPS_SYS_getpid		4020
#define MIPS_SYS_getuid		4024
#define MIPS_SYS_rename		4038
#define MIPS_SYS_dup		4041
#define MIPS_SYS_dup		4041
#define MIPS_SYS_pipe		4042
#define MIPS_SYS_times		4043
#define MIPS_SYS_brk		4045
#define MIPS_SYS_getgid		4047
#define MIPS_SYS_geteuid	4049
#define MIPS_SYS_getegid	4050
#define MIPS_SYS_ioctl		4054
#define MIPS_SYS_dup2		4063
#define MIPS_SYS_setrlimit	4075
#define MIPS_SYS_getrlimit	4076
#define MIPS_SYS_getrusage	4077
#define MIPS_SYS_readlink	4085
#define MIPS_SYS_mmap		4090
#define MIPS_SYS_munmap		4091
#define MIPS_SYS_stat		4106
#define MIPS_SYS_fstat		4108
#define MIPS_SYS_wait4		4114
#define MIPS_SYS_uname		4122
#define MIPS_SYS_llseek		4140
#define MIPS_SYS_nanosleep  4166
#define MIPS_SYS_mremap		4167
#define MIPS_SYS_rt_sigaction	4194
#define MIPS_SYS_rt_sigprocmask	4195
#define MIPS_SYS_fstat64	4215
#define MIPS_SYS_fcntl64	4220
#define MIPS_SYS_exitgroup	4246

//added
#define MIPS_SYS_sysctl		4153

#define NUM_IOCTL_BYTES	128

#define MIPS_O_RDONLY		0
#define MIPS_O_WRONLY		1
#define MIPS_O_RDWR		2
#define MIPS_O_APPEND		0x0008
#define MIPS_O_CREAT		0x0100
#define MIPS_O_TRUNC		0x0200
#define MIPS_O_EXCL		0x0400
#define MIPS_O_NONBLOCK		0x80
#define MIPS_O_NOCTTY		0x800
#define MIPS_O_SYNC		0x10

#define MIPS_PROT_READ       0x1             /* Page can be read.  */
#define MIPS_PROT_WRITE      0x2             /* Page can be written.  */
#define MIPS_PROT_EXEC       0x4             /* Page can be executed.  */
#define MIPS_PROT_NONE       0x0             /* Page can not be accessed.  */

/* Sharing types (must choose one and only one of these).  */
#define MIPS_MAP_SHARED      0x01            /* Share changes.  */
#define MIPS_MAP_PRIVATE     0x02            /* Changes are private.  */

#define MIPS_MAP_FIXED       0x10            /* Interpret addr exactly.  */
#define MIPS_MAP_ANONYMOUS  0x0800          /* Don't use a file.  */

/* open(2) flags translation table for SimpleScalar target */
struct open_flag_map {
	XTInt32 mips_flag;
	XTInt32 local_flag;
};

struct mmap_map {
	XTInt32 mips_flag;
	XTInt32 local_flag;
};
static struct open_flag_map 
mips_flag_table[] = {
	/* target flag */	/* host flag */
	{ MIPS_O_RDONLY,	O_RDONLY },
	{ MIPS_O_WRONLY,	O_WRONLY },
	{ MIPS_O_RDWR,		O_RDWR },
	{ MIPS_O_APPEND,	O_APPEND },
	{ MIPS_O_CREAT,		O_CREAT },
	{ MIPS_O_TRUNC,		O_TRUNC },
	{ MIPS_O_EXCL,		O_EXCL },
	{ MIPS_O_NONBLOCK,	O_NONBLOCK },
	{ MIPS_O_NOCTTY,	O_NOCTTY },
	{ MIPS_O_SYNC,		O_SYNC },
};

#define MMAP_FLAG_COUNT (4)
static struct mmap_map 
mips_mmap_flag_table[] = {
	/* target flag */	/* host flag */
	{ MIPS_MAP_FIXED,	MAP_FIXED },
	{ MIPS_MAP_SHARED, MAP_SHARED },
	{ MIPS_MAP_PRIVATE,  MAP_PRIVATE },
	{ MIPS_MAP_ANONYMOUS,	 MAP_ANONYMOUS},
};

#define MMAP_PROT_COUNT (4)
static struct mmap_map 
mips_mmap_prot_table[] = {
	/* target flag */	/* host flag */
	{ MIPS_PROT_READ,	PROT_READ },
	{ MIPS_PROT_WRITE, PROT_WRITE	 },
	{ MIPS_PROT_EXEC,  PROT_EXEC },
	{ MIPS_PROT_NONE,	 PROT_NONE},
};


#define MIPS_NFLAGS	(sizeof(mips_flag_table)/sizeof(mips_flag_table[0]))

#endif
